/*
* CSET 3600
* Spring Semester 2013
* Melissa Brown
* Josh Siebenaler
* Matt Rich
* Christian Angelo
*
*/
package mancala;

public class EndGameScreen extends javax.swing.JFrame {
    public static int [] WLScores = new int [2];
    
 
    
    

    /**
     * Creates new form EndGameScreen
     */
    public EndGameScreen() {
        
        
        initComponents();
    }
    
    
   

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        playagain = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        homescreen = new javax.swing.JButton();
        Winner = new javax.swing.JLabel();
        WinnerScore = new javax.swing.JLabel();
        Loser = new javax.swing.JLabel();
        LoserScore = new javax.swing.JLabel();
        Name = new javax.swing.JLabel();
        Score = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowOpened(java.awt.event.WindowEvent evt) {
                formWindowOpened(evt);
            }
        });

        playagain.setBackground(new java.awt.Color(153, 153, 153));
        playagain.setText("PLAY AGAIN");
        playagain.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                playagainActionPerformed(evt);
            }
        });

        jButton2.setText("EXIT");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        homescreen.setText("HOME SCREEN");
        homescreen.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                homescreenActionPerformed(evt);
            }
        });

        Winner.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        Winner.setText("jLabel1");

        WinnerScore.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        WinnerScore.setText("jLabel1");

        Loser.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        Loser.setText("jLabel1");

        LoserScore.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        LoserScore.setText("jLabel1");

        Name.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        Name.setText("Name");

        Score.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        Score.setText("Score");

        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .add(44, 44, 44)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(layout.createSequentialGroup()
                        .add(Name)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .add(layout.createSequentialGroup()
                        .add(Loser, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .add(29, 29, 29))
                    .add(layout.createSequentialGroup()
                        .add(Winner, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)))
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, WinnerScore)
                    .add(Score)
                    .add(LoserScore))
                .add(53, 53, 53)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
                    .add(homescreen, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .add(jButton2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .add(playagain, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .add(116, 116, 116))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .add(33, 33, 33)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(Name)
                    .add(Score)
                    .add(playagain))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(WinnerScore)
                    .add(Winner)
                    .add(homescreen))
                .add(18, 18, 18)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(Loser)
                    .add(LoserScore)
                    .add(jButton2))
                .addContainerGap(25, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void formWindowOpened(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowOpened
        // TODO add your handling code here:
       
        
        DisplayValue(WLScores);
        
        
      
    }//GEN-LAST:event_formWindowOpened

    private void playagainActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_playagainActionPerformed
        // TODO add your handling code here:
        
        
        MancalaGameBoardGUI.SetHoleValue = -1;
        
        new MancalaGameBoardGUI().setVisible(true);
        setVisible(false);
        
    }//GEN-LAST:event_playagainActionPerformed

    private void homescreenActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_homescreenActionPerformed
        // TODO add your handling code here:
        
        new HomeScreenGUI().setVisible(true);
        setVisible(false);
    }//GEN-LAST:event_homescreenActionPerformed

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
            System.exit(0);
        // TODO add your handling code here:
    }//GEN-LAST:event_jButton2ActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(EndGameScreen.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(EndGameScreen.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(EndGameScreen.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(EndGameScreen.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                
         
            }
        });
    }
    
    public  String [] DisplayValue(int [] WLScores){
        if(WLScores[0] > WLScores[1]){
            
            WLScores[0] += 1;
            Winner.setText("Player 1");
            WinnerScore.setText(Integer.toString(WLScores[0]));
            
            LoserScore.setText(Integer.toString(WLScores[1]));
            
            if(MancalaGameBoardGUI.computer = true){
                Loser.setText("Computer");
            }
            else{
                Loser.setText("Player 2");
            }
        }
        else{
            
            WLScores[1] +=1;
            
            WinnerScore.setText(Integer.toString(WLScores[1]));
            Loser.setText("Player 1");
            LoserScore.setText(Integer.toString(WLScores[0]));
            
            if(MancalaGameBoardGUI.computer = true){
                Winner.setText("Computer");
            }
            else{
                Winner.setText("Player 2");
            }
        }
        
        
        
        return null;
        
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel Loser;
    private javax.swing.JLabel LoserScore;
    private javax.swing.JLabel Name;
    private javax.swing.JLabel Score;
    private javax.swing.JLabel Winner;
    private javax.swing.JLabel WinnerScore;
    private javax.swing.JButton homescreen;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton playagain;
    // End of variables declaration//GEN-END:variables
}
